var t = require;
var e = module;
var o = exports;
var n =
        (this && this.__extends) ||
        (function () {
            var t = function (e, o) {
                return (t =
                    Object.setPrototypeOf ||
                    ({__proto__: []} instanceof Array &&
                        function (t, e) {
                            t.__proto__ = e;
                        }) ||
                    function (t, e) {
                        for (var o in e) e.hasOwnProperty(o) && (t[o] = e[o]);
                    })(e, o);
            };
            return function (e, o) {
                function n() {
                    this.constructor = e;
                }
                t(e, o), (e.prototype = null === o ? Object.create(o) : ((n.prototype = o.prototype), new n()));
            };
        })(),
    r =
        (this && this.__decorate) ||
        function (t, e, o, n) {
            var r,
                a = arguments.length,
                i = a < 3 ? e : null === n ? (n = Object.getOwnPropertyDescriptor(e, o)) : n;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) i = Reflect.decorate(t, e, o, n);
            else
                for (var s = t.length - 1; s >= 0; s--)
                    (r = t[s]) && (i = (a < 3 ? r(i) : a > 3 ? r(e, o, i) : r(e, o)) || i);
            return a > 3 && i && Object.defineProperty(e, o, i), i;
        };
Object.defineProperty(o, "__esModule", {value: !0});
var a = t("fightManager"),
    i = t("telepole"),
    s = cc._decorator,
    c = s.ccclass,
    l =
        (s.property,
        (function (t) {
            function e() {
                var e = (null !== t && t.apply(this, arguments)) || this;
                return (e.up = !1), (e.down = !1), (e.left = !1), (e.right = !1), e;
            }
            return (
                n(e, t),
                (e.prototype.onLoad = function () {
                    cc.systemEvent.on(cc.SystemEvent.EventType.KEY_DOWN, this.onKeyDown, this),
                        cc.systemEvent.on(cc.SystemEvent.EventType.KEY_UP, this.onKeyUp, this);
                }),
                (e.prototype.onDestroy = function () {
                    cc.systemEvent.off(cc.SystemEvent.EventType.KEY_DOWN, this.onKeyDown, this),
                        cc.systemEvent.off(cc.SystemEvent.EventType.KEY_UP, this.onKeyUp, this);
                }),
                (e.prototype.有方向按钮按下 = function () {
                    return !!this.up || !!this.down || !!this.left || !!this.right || void 0;
                }),
                (e.prototype.按下摇杆 = function () {
                    i.default.inst.state.onTouchStart(cc.v2());
                }),
                (e.prototype.按下方向按钮 = function (t, e) {
                    this.有方向按钮按下() || this.按下摇杆(), e.call(t);
                    var o = cc.v2();
                    this.up && (o.y += 50),
                        this.down && (o.y -= 50),
                        this.left && (o.x -= 50),
                        this.right && (o.x += 50),
                        i.default.inst.state.onTouchMove(o);
                }),
                (e.prototype.弹起方向按钮 = function (t, e) {
                    if ((e.call(t), this.有方向按钮按下())) {
                        var o = cc.v2();
                        this.up && (o.y += 50),
                            this.down && (o.y -= 50),
                            this.left && (o.x -= 50),
                            this.right && (o.x += 50),
                            i.default.inst.state.onTouchMove(o);
                    } else i.default.inst.state.onTouchEnd();
                }),
                (e.prototype.onKeyDown = function (t) {
                    var e = this;
                    switch (t.keyCode) {
                        case cc.macro.KEY.w:
                            this.按下方向按钮(this, function () {
                                e.up = !0;
                            });
                            break;
                        case cc.macro.KEY.s:
                            this.按下方向按钮(this, function () {
                                e.down = !0;
                            });
                            break;
                        case cc.macro.KEY.a:
                            this.按下方向按钮(this, function () {
                                e.left = !0;
                            });
                            break;
                        case cc.macro.KEY.d:
                            this.按下方向按钮(this, function () {
                                e.right = !0;
                            });
                    }
                }),
                (e.prototype.onKeyUp = function (t) {
                    var e = this;
                    switch (t.keyCode) {
                        case cc.macro.KEY.h:
                            a.default.inst.on_player_attack();
                            break;
                        case cc.macro.KEY.j:
                            a.default.inst.on_player_skill(0);
                            break;
                        case cc.macro.KEY.k:
                            a.default.inst.on_player_skill(1);
                            break;
                        case cc.macro.KEY.l:
                            a.default.inst.on_player_skill(2);
                            break;
                        case cc.macro.KEY.w:
                            this.弹起方向按钮(this, function () {
                                e.up = !1;
                            });
                            break;
                        case cc.macro.KEY.s:
                            this.弹起方向按钮(this, function () {
                                e.down = !1;
                            });
                            break;
                        case cc.macro.KEY.a:
                            this.弹起方向按钮(this, function () {
                                e.left = !1;
                            });
                            break;
                        case cc.macro.KEY.d:
                            this.弹起方向按钮(this, function () {
                                e.right = !1;
                            });
                    }
                }),
                (e = r([c], e))
            );
        })(cc.Component));
o.default = l;
